/*********************************
* John Clayton
* Assignment 3
* CS362
* isGameOver test
*********************************/

#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <math.h>

#define NUM_TESTS 10 //Number of times to run the test

int main(){
   int i, j, k, player, numPlayers, handPos, opt1, opt2, opt3,
       bonus = 1;
   int* handCounts;
   int* kCards;
   struct gameState *state;
   enum CARD card = council_room;
   enum CARD firstCard = adventurer;
   enum CARD lastCard = treasure_map;
   PlantSeeds(3);
   SelectStream(0);
   assert(state != 0);

   printf("Beginning testing unit: isGameOver\n**************************************\n");
   for(i = 0; i <= NUM_TESTS; i++){
      state = newGame();
      numPlayers = (((int) (Random() * 1000))%4) + 1;
      kCards = kingdomCards((int) (Random() * 256) % (lastCard - firstCard) + firstCard,
	    (int) (Random() * 256) % (lastCard - firstCard) + firstCard,
	    (int) (Random() * 256) % (lastCard - firstCard) + firstCard,
	    (int) (Random() * 256) % (lastCard - firstCard) + firstCard,
	    (int) (Random() * 256) % (lastCard - firstCard) + firstCard,
	    (int) (Random() * 256) % (lastCard - firstCard) + firstCard,
	    (int) (Random() * 256) % (lastCard - firstCard) + firstCard,
	    (int) (Random() * 256) % (lastCard - firstCard) + firstCard,
	    (int) (Random() * 256) % (lastCard - firstCard) + firstCard,
	    (int) (Random() * 256) % (lastCard - firstCard) + firstCard);
      initializeGame(numPlayers, kCards,(int) (Random()*256), state);
      if(isGameOver(state) == 1)
	 printf("[Test %d] Incorrectly claims game is over after initialization\n", i);
      state->supplyCount[province] = 0;
      if(isGameOver(state) == 0)
	 printf("[Test %d] Incorrectly claims game is not over when no provinces\n", i);
      state->supplyCount[province] = 3;
      state->supplyCount[adventurer] = 0;
      state->supplyCount[baron] = 0;
      state->supplyCount[embargo] = 0;
      if(isGameOver(state) == 0)
	 printf("[Test %d] Incorrectly claims game is not over when 3 decks empty\n", i);
   }
   printf("Ending testing unit: isGameOver\n***********************************\n");
   return 0;
}
